<?php
set_time_limit(0);
/*
	pmis_outing_map_inc.php
	
	This file is the main file for PMIS->OUTING table mapping ... 
	This file is used to import/update data from PMIS ...
	Any changes in table names/fields should be define here

*/

// Mapping PMIS -> outing DB ...
$tbl_map_arr = array(
					"tblPerson"=>"profiles",
					"tblStudent"=>"students",
					"tblDepartment"=>"departments",
					"tblJurusan"=>"courses",
					"tblStudentProgram"=>"student_course",
					"tblBlock"=>"hostel_blocks",
					"tblCheckIn"=>"student_blocks"
					);
// ------------ START tblPerson MAP -----------------------------------
// Mapping fields in the PMIS table -> Outing table
$tblPerson_map = array(
						"ICNumber"=>"ic_new", 
						"Name"=>"name", 
						"Religion"=>"religion_id", 
						"Race"=>"race_id",
						"Sex"=>"gender_id", 
						"DOB"=>"date_of_birth", 
						"Nationality"=>"nationality_id", 
						"Address1"=>"address_line1", 
						"Address2"=>"address_line2", 
						"Address3"=>"address_line3", 
						"Town"=>"address_city", 
						"PostCode"=>"address_postcode",
						"State"=>"address_state_id"
						);
$tblPerson_fields = array();
$profiles_fields = array();

// Create array of field name in PMIS and field name in Outing 
foreach($tblPerson_map as $key=>$val){
	$tblPerson_fields[]=$key;
	$profiles_fields[]=$val;
}
// create string to form SQL string 
$tblPerson_field_str = join(",", $tblPerson_fields);										
$profiles_field_str = join(",", $profiles_fields);				
// ------------ END tblPerson MAP -----------------------------------

// ------------ START tblStudent MAP -----------------------------------
$tblStudent_map = array(
						"icnumber"=>"ic_new",
						"studentid"=>"nomatrik"
						);
$tblStudent_fields	= array();
$students_fields = array();
					
foreach($tblStudent_map as $k=>$v){
	$tblStudent_fields[] = $k;
	$students_fields[] = $v;
}
$tblStudent_field = join(",", $tblStudent_fields);
$students_field = join(",", $students_fields);

// ------------ END tblStudent MAP -----------------------------------

// ------------ START tblCheckIn MAP -----------------------------------

$tblCheckIn_map = array(
						"icnumber"=>"ic_new",
						"roomname"=>"hostel_block_id"
						);
$tblCheckIn_fields	= array();
$student_blocks_fields = array();
					
foreach($tblCheckIn_map as $k=>$v){
	$tblCheckIn_fields[] = $k;
	$student_blocks_fields[] = $v;
}
$tblCheckIn_field = join(",", $tblCheckIn_fields);
$student_blocks_field = join(",", $student_blocks_fields);
// ------------ END tblCheckIn MAP -----------------------------------

// ------------ START tblBlock  hostelMAP -----------------------------------
$tblBlock_map = array(
						"blockname"=>"code",
						"buildingname"=>"description"
						);
$tblBlock_fields	= array();
$hostel_blocks_fields = array();
					
foreach($tblBlock_map as $k=>$v){
	$tblBlock_fields[] = $k;
	$hostel_blocks_fields[] = $v;
}
$tblBlock_field = join(",", $tblBlock_fields);
$hostel_blocks_field = join(",", $hostel_blocks_fields);

// ------------ END tblBlock hostel MAP -----------------------------------

// ------------ START tbljurusan MAP -----------------------------------

$tblJurusan_map = array(
						"programcode"=>"code",
						"programname"=>"name"
						);
$tblJurusan_fields = array();
$courses_fields = array();

foreach($tblJurusan_map as $k=>$v){
	$tblJurusan_fields[] = $k;
	$courses_fields[] = $v;
}

$tblJurusan_field = join(",", $tblJurusan_fields);
$courses_field = join(",", $courses_fields);

// ------------ END tblJurusan MAP -----------------------------------

// ------------ START tblDepartment MAP -----------------------------------

$tblDepartment_map = array(
						"deptcode"=>"code",
						"deptname"=>"description"
						);

						$tblDepartment_fields = array();
$departments_fields = array();				
foreach($tblDepartment_map as $k=>$v){
	$tblDepartment_fields[] = $k;
	$departments_fields[] = $v;
}

$tblDepartment_field = join(",", $tblDepartment_fields);
$departments_field = join(",", $departments_fields);

// ------------ END tblDepartment MAP -----------------------------------

// ------------ START tblStudentProgram MAP -----------------------------------

$tblStudentProgram_map = array(
						"studentid"=>"nomatrik",
						"programcode"=>"course_id"
						);

$tblStudentProgram_fields = array();
$departments_fields = array();				

foreach($tblStudentProgram_map as $k=>$v){
	$tblStudentProgram_fields[] = $k;
	$student_course_fields[] = $v;
}

$tblStudentProgram_field = join(",", $tblStudentProgram_fields);
$student_course_field = join(",", $student_course_fields);

// ------------ END tblStudentProgram MAP -----------------------------------

$religion_arr = array(
					"O"=>"1",
					"I"=>"1",  
					"B"=>"2", 
					"H"=>"3", 
					"K"=>"4", 
					"L"=>"5" 
					);    

$races_arr = array(  
					   "B" =>"2", 
					   "C" =>"3",
					   "D" =>"4",
					   "I" =>"5",
					   "L" =>"7",
					   "M" =>"8",
					   "R" =>"9",
					   "S" =>"10",
					   "T" =>"11",
					   "K" =>"6",
					   "O" =>"1",
					   "S" =>"12"    
					);       
$gender_arr = array("L"=>"1","P"=>"2");

$state_arr = array(
					 "J" =>"1",
					 "K" =>"2",
					 "D" =>"3",
					 "M" =>"4",
					 "N" =>"5",
					 "C" =>"6",
					 "P" =>"7",
					 "A" =>"8",
					 "R" =>"9",
					 "B" =>"10",
					 "T" =>"11",
					 "S" =>"12",
					 "Q" =>"13",
					 "W" =>"14",
					 "L" =>"15",
					 "Y" =>"16"
					);    

$nasionality_arr = array ( "Y"=>"1", " "=>"0");


//$outingdb_link = db_connect();
//$pmisdb_link = db_connectku();

?>
